package com.xm.interview;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author：xm
 * @Project：runoob
 * @Date：2024/11/8 23:35
 */

// 描述：java 三年，25-35k面试真题
/*
Map<User,Object>
User{
    String name;
    Integer age;
    Integer gender;
}

User01 user01 = new User01("u01",18,1);
User01 user02 = new User01("u01",18,1);
User01 user03 = new User01("u03",20,0);

map.get(user01)==map.get(user02)!=map.get(user03);
 */
public class _01_Question {

    String name;
    Integer age;
    Integer gender;

    public static void main(String[] args) {
        _01_User user01 = new _01_User("u01", 18, 1);
        _01_User user02 = new _01_User("u01", 18, 1);
        _01_User user03 = new _01_User("u03", 20, 0);

        System.out.println("user01 = " + user01);
        System.out.println("user02 = " + user02);
        System.out.println("user03 = " + user03);

        System.out.println("user01.hashCode() = " + user01.hashCode());
        System.out.println("user02.hashCode() = " + user02.hashCode());
        System.out.println("user03.hashCode() = " + user03.hashCode());

        String str = "u01181";
        System.out.println("str.hashCode() = " + str.hashCode());
        char[] charArray = str.toCharArray();
        System.out.println("charArray = " + charArray);
        for (char c : charArray) {
            System.out.print(c);
        }
        System.out.println();

        Map map = new HashMap<String,Integer>();
        map.put(user01.hashCode(), "u01");

        System.out.println("map.get(user01) = " + map.get(user01.hashCode()));
        System.out.println("map.get(user02) = " + map.get(user02.hashCode()));

        if (map.get(user01.hashCode()) == map.get(user02.hashCode()) && map.get(user02.hashCode()) != map.get(user03.hashCode())) {
            System.out.println("ok");
        }

    }

}
